$(document).ready(function() {
	displayFaculty();
	displayProject();
	var currentUrl = window.location.href;
	var idFaculty = currentUrl.slice(currentUrl.indexOf('#') + 1);
	getFaculty(idFaculty);
	
});

$(window).bind('hashchange', function() {
	location.reload();
});

function getFaculty(idFaculty){
	var params = {
		action: 'getById',
		idFaculty: idFaculty
	};
	sendRequest(URL_FACULTY, 'GET', params, function(res){
		var data = JSON.parse(res);
		if(data){
			var faculty = data;
			$('.facultyName').text(faculty.Name);
			$('#facultyDiploma').text(faculty.Diploma);
			$('#facultyDepartment').text(faculty.Department);
			$('#facultyProcess').html(faculty.Process);
			$('#facultyPerformance').html(faculty.Performance);
			$('#facultyDesc').html(faculty.Desc);
			$('#facultyImage').attr('src', faculty.Image);
			for(var index in faculty.Project){
				$('#facultyProject').append(drawLi('').append(drawA('', PROJECT_DETAIL+'#'+faculty.Project[index].Id, faculty.Project[index].Title)));
			}
		}
	}, function(err){
	});
}